﻿
Imports osi.service.convertor
Imports osi.service.http.constants

Public Class link_status
    Public ReadOnly timeout_ms As Int64
    Public ReadOnly buff_size As Int32
    Public ReadOnly single_copy_timeout_ms As Int64
    Public ReadOnly copy_timeout_ms As Int64
    Public ReadOnly max_content_length As Int64

    Public Function over_max_content_length(ByVal l As Int64) As Boolean
        Return l >= 0 AndAlso
               max_content_length >= 0 AndAlso
               l > max_content_length
    End Function

    Public Sub New(ByVal timeout_ms As Int64,
                   Optional ByVal buff_size As Int32 = default_value.buff_size,
                   Optional ByVal single_copy_timeout_ms As Int64 = default_value.single_copy_timeout_ms,
                   Optional ByVal copy_timeout_ms As Int64 = default_value.copy_timeout_ms,
                   Optional ByVal max_content_length As Int64 = default_value.max_content_length)
        Me.timeout_ms = timeout_ms
        Me.buff_size = buff_size
        Me.single_copy_timeout_ms = single_copy_timeout_ms
        Me.copy_timeout_ms = copy_timeout_ms
        Me.max_content_length = max_content_length
    End Sub

    Public Sub New(ByVal timeout_ms As String,
                   ByVal buff_size As String,
                   ByVal single_copy_timeout_ms As String,
                   ByVal copy_timeout_ms As String,
                   ByVal max_content_length As String)
        Me.New(timeout_ms.to_int64(default_value.connect_timeout_ms),
               buff_size.to_int32(default_value.buff_size),
               single_copy_timeout_ms.to_int64(default_value.single_copy_timeout_ms),
               copy_timeout_ms.to_int64(default_value.copy_timeout_ms),
               max_content_length.to_int64(default_value.max_content_length))
    End Sub

    Public Shared ReadOnly request As link_status
    Public Shared ReadOnly response As link_status
    Public Shared ReadOnly server As link_status

    Shared Sub New()
        request = New link_status(default_value.connect_timeout_ms)
        response = New link_status(default_value.response_timeout_ms)
        server = New link_status(0)
    End Sub
End Class
